package com.atguigu.eduService.controller;


import com.atguigu.commonUtils.Result;
import com.atguigu.commonUtils.ResultEnum;
import com.atguigu.commonUtils.ResultUtil;
import com.atguigu.eduService.entity.EduVideo;
import com.atguigu.eduService.service.EduVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author Chen Wen bo
 * @since 2021-07-22
 */
@Api(tags = "课程小节")
@RestController
@RequestMapping("/eduService/video")
@CrossOrigin
public class EduVideoController {

    @Resource
    private EduVideoService eduVideoService;

    @ApiOperation("添加小节")
    @PostMapping("/addVideo")
    public Result<EduVideo> addVideo(@RequestBody EduVideo eduVideo){
        eduVideoService.addVideo(eduVideo);
        return ResultUtil.success();
    }

    @ApiOperation("删除小节")
    @DeleteMapping("/deleteVideo/{id}")
    public Result<EduVideo> deleteVideo(@PathVariable String id){
        eduVideoService.deleteVideo(id);
        return ResultUtil.success();
    }

    @ApiOperation("根据id查询小节")
    @GetMapping("/getVideo/{id}")
    public Result<EduVideo> getVideo(@PathVariable String id){
        EduVideo eduVideo = eduVideoService.getVideo(id);
        return ResultUtil.success(eduVideo);
    }

    @ApiOperation("修改小节")
    @PutMapping("/updateVideo")
    public Result<EduVideo> updateVideo(@RequestBody EduVideo eduVideo){
        eduVideoService.updateVideo(eduVideo);
        return ResultUtil.success();
    }

}

